package ys.com;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
import ys.com.config.AppConfig;

@RestController
@EnableAutoConfiguration
public class Example {

//    @Autowired
  static   AppConfig appConfig;

    @RequestMapping("/")
    String home() {
        return "Hello World!"+appConfig.getProfiles();
    }

    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
        ctx.getEnvironment().setActiveProfiles("dev");
        ctx.register(AppConfig.class);
//        ctx.refresh();
        appConfig = ctx.getBean(AppConfig.class);
        SpringApplication.run(Example.class, args);
    }

}